<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>user</title>
</head>
<body>

<section>



<h2>增加用户</h2>

<div>
  <label for="id">id</label>
  <input type="text" id="id">
</div>

<div>
  <label for="name">name</label>
  <input type="text" id="name">
</div>

<div>
  <label for="age">age</label>
  <input type="text" id="age">
</div>

<div>
  <label for="points">points</label>
  <input type="text" id="points">
</div>

<button id="sub">提交</button>

</section>

<section>
  <h2>赠送积分</h2>
  <div>
    <label for="from">赠送方</label>
    <input type="text" id="from">
  </div>
  <div>
    <label for="accept">受让方</label>
    <input type="text" id="accept">
  </div>
  <div>
    <label for="num">数量</label>
    <input type="text" id="num">
  </div>

  <button id="send">交易</button>
</section>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<script>

  $(function () {
      $("#sub").on("click", function () {
          let data = {
              id: $("#id").val(),
              name: $("#name").val(),
              age: $("#age").val(),
              points: $("#points").val(),
          }
          $.ajax({
              type: 'POST',
              url: "/users/addUser",
              data: data,
              dataType: 'json',
              success: function (r) {
                  console.log(r)
              },
          });
      })
  })
</script>

<script>
  $(function () {
      $("#send").on("click", function () {
          let data = {
              from: $("#from").val(),
              accept: $("#accept").val(),
              num: $("#num").val(),
          }
          $.ajax({
              type: 'GET',
              url: "/users/sendPoints",
              data: data,
              dataType: 'json',
              success: function (r) {
                  console.log(r)
              },
          });
      })
  })


</script>

</body>
</html>